#!/usr/bin/env bash

cat <<EOF >mise.toml
[tasks.a]
run = "echo a"

[tasks.b]
depends = ["a"]
run = "echo b"

[tasks.c]
wait_for = ["b"]
run = "echo c"

[tasks.d]
depends = ["b"]
depends_post = ["c"]
run = "echo d"

[tasks.e]
run = [{ task = "a" }, { task = "b" }]
EOF

# Test normal, with dependencies
assert "mise run d" "a
b
d
c"

# Test --skip-deps
assert "mise run d --skip-deps" "d"
assert "MISE_TASK_SKIP_DEPENDS=true mise run d" "d"

# Test --skip-deps, multiple tasks
assert_contains "mise run c --skip-deps ::: b" "c"
assert_contains "mise run c --skip-deps ::: b" "b"
assert_not_contains "mise run c --skip-deps ::: b" "a"

# Test --skip-deps, nested dependencies
assert "mise run e --skip-deps" "a
b"

# Test task_skip_depends setting
cat <<EOF >mise.toml
[settings]
task_skip_depends = true

[tasks.a]
run = "echo a"

[tasks.b]
depends = ["a"]
run = "echo b"

[tasks.f]
run = [{ task = "a" }, { task = "b" }]
EOF

assert "mise run b" "b"
assert "mise run f" "a
b"
